/*
 *      SequenciableSSA.java
 *
 *      Copyright 2008 Pablo Nicolas Diaz Bilotto <pablonicolas.diaz@gmail.com>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

package ilanguage.iltokens;


/*Tokens Secuenciables y no descartables*/

/**
 *
 * la idea con este es tener codigo para las
 * secuencias de tokens
 *
 * The Class SequenciableSSA.
 */
public class SequenciableSSA extends IL_SSA {

    /*
     * (non-Javadoc)
     *
     * @see ilanguage.iltokens.ILToken#GenerateCodeMachine()
     */

    /**
     * Gets the next seq.
     *
     * @return the next seq
     */
    protected static synchronized int getNextSeq() {
        return Sequence++;
    }

    /**
     * Reset sequence.
     */
    public static synchronized void resetSequence() {
        Sequence = 0;
    }

    /** The ref print. */
    private boolean refPrint;

    /** The Sequence. */
    protected static int Sequence = 0;

    /** The Seq. */
    private int Seq = getNextSeq();

    /**
     * Instantiates a new sequenciable ssa.
     */
    public SequenciableSSA() {
        super();
    }

    /**
     * Gets the prefix.
     *
     * @return the prefix
     */
    public String getPrefix() {
        return "IL(" + Integer.toString(this.getSeq()) + ")";
    }

    /**
     * Gets the seq.
     *
     * @return the seq
     */
    public int getSeq() {
        return Seq;
    }

    /*
     * (non-Javadoc)
     *
     * @see ilanguage.ILToken#getSequence()
     */
    public String getSequence() {
        if (this.isRefPrint()) {
			return "L_" + getSeq();
		}
        return "";
    }

    /*
     * (non-Javadoc)
     *
     * @see ILanguage.IL_Token#GetValue()
     */
    public Object getValue() {
        return "IL(" + Integer.toString(this.getSeq()) + ")";
    }

    /*
     * (non-Javadoc)
     *
     * @see ILanguage.IL_Token#IsDiscartable()
     */
    public boolean isDiscartable() {
        return false;
    }

    /*
     * (non-Javadoc)
     *
     * @see ilanguage.ILToken#isRefPrint()
     */
    public boolean isRefPrint() {
        return refPrint;
    }

    /*
     * (non-Javadoc)
     *
     * @see ilanguage.ILToken#setRefPrint(boolean)
     */
    public void setRefPrint(boolean refPrint) {
        this.refPrint = refPrint;
    }

    /**
     * Sets the seq.
     *
     * @param seq the new seq
     */
    public void setSeq(int seq) {
        Seq = seq;
    }

    /*
     * (non-Javadoc)
     *
     * @see ILanguage.IL_Token#toString()
     */
    public String toString() {
        return this.getPrefix();
    }

}